<template>
  <div class="app-container p-rel">
    <div class="container-title">医师计分记录</div>

    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item prop="enterpriseName">
        <el-input
          v-model="queryParams.enterpriseName"
          placeholder="请输入医疗机构名称"
          clearable
          @keyup.enter.native="search"
        />
      </el-form-item>
      <el-form-item prop="physicianName">
        <el-input
          v-model="queryParams.physicianName"
          placeholder="请输入医师名称"
          clearable
          @keyup.enter.native="search"
        />
      </el-form-item>

      <el-form-item prop="reason">
        <el-input
          v-model="queryParams.reason"
          placeholder="请输入记分原因"
          clearable
          @keyup.enter.native="search"
        />
      </el-form-item>
    </el-form>

    <div class="mb-4">
      <el-button type="primary" icon="" size="" @click="search">搜索</el-button>
      <el-button icon="" size="" @click="reset">重置</el-button>
      <el-button type="primary" @click="toAddPage">添加记分</el-button>
    </div>

    <el-table v-loading="loading" :data="dataList" border>
      <el-table-column type="index" width="55" align="center" label="序号" />
      <el-table-column
        label="医疗机构名称"
        align="center"
        prop="enterpriseName"
      />
      <el-table-column label="医生名称" align="center" prop="physicianName" />
      <el-table-column label="记分数值" align="center" prop="scoring" />
      <el-table-column label="记分原因" align="center" prop="reason" />
      
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getDataList"
    />
  </div>
</template>

<script>

import {getDoctorScoringListAPI} from '@/api/zhangping/health-care/doctor-scoring'

export default {
  

  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 医师计分记录表格数据
      dataList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        enterpriseName: null,
        creditCode: null,
        identityNumber: null,
        physicianName: null,
        scoring: null,
        reason: null,
        createId: null,
        updateId: null,
        startTime: "",
        endTime: "",
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      detailForm: {},
      isEdit: false,
      editVisible: false,
      datePickerTime: [],
    };
  },
  created() {
    this.getDataList();
  },
  methods: {
    toAddPage() {
      const obj = {
        path: "/health-care/doctor-scoring-edit",
      };
      this.$router.push(obj);
    },
    /** 查询医师计分记录列表 */
    getDataList() {
      this.loading = true;

      this.queryParams.startTime = this.datePickerTime
        ? this.datePickerTime[0]
        : "";
      this.queryParams.endTime = this.datePickerTime
        ? this.datePickerTime[1]
        : "";
        getDoctorScoringListAPI(this.queryParams).then((response) => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    
    /** 搜索按钮操作 */
    search() {
      this.queryParams.pageNum = 1;
      this.getDataList();
    },
    /** 重置按钮操作 */
    reset() {
      this.datePickerTime = [];
      this.resetForm("queryForm");
      this.search();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.detailForm = {};
      this.isEdit = false;
      this.editVisible = true;
    },
    handleAdd777() {
      alert("待确认页面做");
    },
    /** 修改按钮操作 */
    handleUpdate(row, type) {
      // this.reset();
      const id = row.id || this.ids;
      getScoring(id).then((response) => {
        this.detailForm = response.data;
        if (type == 1) {
          this.isEdit = true;
        } else {
          // 查看
          this.isEdit = false;
        }
        this.editVisible = true;
      });
    },
    /** 提交按钮 */
    submitForm(form, id) {
      if (id != null) {
        updateScoring(form).then((response) => {
          this.$modal.msgSuccess("修改成功");
          this.editVisible = false;
          this.getDataList();
        });
      } else {
        addScoring(form).then((response) => {
          this.$modal.msgSuccess("新增成功");
          this.editVisible = false;
          this.getDataList();
        });
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除医师计分记录编号为"' + ids + '"的数据项？')
        .then(function () {
          return delScoring(ids);
        })
        .then(() => {
          this.getDataList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "zpMedicalOrgPhysician/scoring/export",
        {
          ...this.queryParams,
        },
        `scoring_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style lang="scss" scoped>
.app-container {
  .tableBtnListCss {
    margin-top: 10px;
    padding-top: 10px;
  }
}
</style>
